import React, { useContext, useEffect, useState } from 'react';
import { contAppInfo } from 'context/appInfo';
import Pdf from './pdf';
import styles from './index.less';

/**
 * cfg 配置信息
 * api 接口数据
 * EventBus 用做组件数据交互
 */

const PdfViewer = (props: any) => {
  const { file, maxZoom, renderType, fileName, responseType} = props;

  useEffect(() => {
    if (fileName) {
      setTimeout(() => {
        document.title = fileName?.split('.pdf')?.[0]
      }, 300)
    }
  }, [fileName])
  return (
    <div className={styles.main}>
          {file ? (
            <Pdf src={file} renderType={renderType} maxZoom={maxZoom} responseType={responseType}/>
          ) : (
            <div className={styles.prompt}>文件路径为空，请提供有效的文件。</div>
          )}
        </div>
  );
};
export default PdfViewer;
    